#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;
using ll=long long;
bool check(ll llNum){
	
	if(llNum<0){
		return false;
	}
	ll llTmp=static_cast<ll>(sqrt(llNum));
	return llTmp*llTmp==llNum;
}
int main() {

	ll llNum;
	cin>>llNum;
	ll llDif=0;
	while(!check(llNum-llDif) && !check(llNum+llDif)){
		++llDif;
	}
	cout<<(check(llNum-llDif)?(llNum-llDif):(llNum+llDif));
	
	return 0;
}
